package com.sk.bilibili.adapter.pager.videoSet;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.sk.bilibili.adapter.pager.BaseFragmentAdapter;
import com.sk.bilibili.view.fragment.DiscussFragment;
import com.sk.bilibili.view.fragment.videoSet.IntroductionFragment;

public class VideoSetFragmentAdapter extends BaseFragmentAdapter {

    private Integer videoSetId;

    public VideoSetFragmentAdapter(@NonNull FragmentManager fm,Integer videoSetId) {
        super(fm);
        this.videoSetId=videoSetId;
        initData();
    }

    private static final String[] TITLES ="简介,评论".split(",");

    @Override
    protected String[] getTitles() {
        return TITLES;
    }

    private IntroductionFragment introductionFragment;

    @Override
    protected Fragment[] getFragments() {
        Fragment[] fragments=new Fragment[2];
        fragments[0]=introductionFragment=new IntroductionFragment(videoSetId);
        fragments[1]=new DiscussFragment(videoSetId,0);
        return fragments;
    }

    public void setDiscussNum(Integer discussNum) {
        TITLES[1]="评论"+discussNum;
        notifyDataSetChanged();
    }

    public void setSelection(int selection) {
        introductionFragment.setSelection(selection);
    }

}